Telegram Group & Telegram Channel
Что выведет следующий код на C#?


using System;

class Program {
static void Main() {
int a = 1000;
int b = 1000;

object x = a;
object y = b;

Console.WriteLine(x == y); // #1
Console.WriteLine(x.Equals(y)); // #2
}
}


🔢 Варианты ответа:

A)

True


B)

False


C)

True


D)

False


Правильный ответ: C

💡 Почему?

-
x и y — boxed значения типа int, то есть ссылки на два разных объекта в куче.
-
x == y сравнивает ссылки, а не значения → False.
-
x.Equals(y) вызывает метод Equals для int, который сравнивает значения → True.

📌 Подвох — в различии
== и .Equals() при использовании упакованных типов.

@csharp_ci



tg-me.com/csharp_ci/1336
Create:
Last Update:

Что выведет следующий код на C#?


using System;

class Program {
static void Main() {
int a = 1000;
int b = 1000;

object x = a;
object y = b;

Console.WriteLine(x == y); // #1
Console.WriteLine(x.Equals(y)); // #2
}
}


🔢 Варианты ответа:

A)

True


B)

False


C)

True


D)

False


Правильный ответ: C

💡 Почему?

-
x и y — boxed значения типа int, то есть ссылки на два разных объекта в куче.
-
x == y сравнивает ссылки, а не значения → False.
-
x.Equals(y) вызывает метод Equals для int, который сравнивает значения → True.

📌 Подвох — в различии
== и .Equals() при использовании упакованных типов.

@csharp_ci

BY C# (C Sharp) programming


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/csharp_ci/1336

View MORE
Open in Telegram


C C Sharp programming Telegram | DID YOU KNOW?

Date: |

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

What is Telegram?

Telegram’s stand out feature is its encryption scheme that keeps messages and media secure in transit. The scheme is known as MTProto and is based on 256-bit AES encryption, RSA encryption, and Diffie-Hellman key exchange. The result of this complicated and technical-sounding jargon? A messaging service that claims to keep your data safe.Why do we say claims? When dealing with security, you always want to leave room for scrutiny, and a few cryptography experts have criticized the system. Overall, any level of encryption is better than none, but a level of discretion should always be observed with any online connected system, even Telegram.

C C Sharp programming from br


Telegram C# (C Sharp) programming
FROM USA